package main

import (
	"encoding/json"
	"fmt"
)

type response1 struct {
	Page   int
	Fruits []string
}

type response2 struct {
	Page   int      `json."page"`
	Fruits []string `json:fruits`
}

func main() {
	bolB, _ := json.Marshal(true)
	fmt.Println(string(bolB))

	intB, _ := json.Marshal(1)
	fmt.Println(string(intB))

	fltB, _ := json.Marshal(2.34)
	fmt.Println(string(fltB))

	strB, _ := json.Marshal("gopher")
	fmt.Println(string(strB))

	slcD := []string{"apple", "peache", "pear"}
	slcB, _ := json.Marshal(slcD)
	fmt.Println(string(slcB))

	reslD := &response1{
		Page:   1,
		Fruits: []string{"apple", "peach", "pear"}}

	reslB, _ := json.Marshal(reslD)
	fmt.Println(string(reslB))

	res2D := &response2{
		Page:   1,
		Fruits: []string{"apple", "peach", "pear"}}

	res2B, _ := json.Marshal(res2D)
	fmt.Println(string(res2B))

	byt := []byte(`{"num":6.13, "strs":["a", "b"]}`)

	var dat map[string]interface{}

	if err := json.Unmarshal(byt, &dat); err != nil {
		panic(err)
	}

	fmt.Println(dat)

	num := dat["num"].(float64)

	fmt.Println(num)

	strs := dat["strs"].([]interface{})

	strl := strs[0].(string)

	fmt.Println(strl)

}
